package com.jiangruanjavaproject.service;

import com.alibaba.fastjson.JSONObject;
import com.jiangruanjavaproject.Constants;
import com.jiangruanjavaproject.bean.HotVideo;
import com.jiangruanjavaproject.bean.HotVideoCommon;
import com.jiangruanjavaproject.request.HttpUtils;

import java.util.List;

/**
 * @author:wanfeng
 * @desc:
 * @datetime:2021/12/14 20:01
 */
public class HotVideoService {
    public List<HotVideo> getHotVodeo(){

    // 该方法用于获取热门数据，并将热门数据返回
    
    String url = Constants.CAR_URL
            +"?key=" + Constants.CAR_KEY
            +"&type=hot_video"
            +"&size=20";
    String result = HttpUtils.get(url);
    System.out.println(result);

    //json解析
    HotVideoCommon videoCommon = JSONObject.parseObject(result, HotVideoCommon.class);
    System.out.println(videoCommon.error_code);
    System.out.println(videoCommon.reason);
    System.out.println(videoCommon.result.size());
    return videoCommon.result;


}
}